package com.xcw.test;

import com.xcw.function.normal.ConsumerInter;

import java.util.*;

/**
 * @Author bhx
 * @Date 2022/8/9 2:27
 * @Description TODO
 */
public class ComparatorDemo {
    public static Comparator<String> getComparator(){
//        return new Comparator<String>() {
//            @Override
//            public int compare(String o1, String o2) {
//                return o1.length() - o2.length();
//            }
//        };
        return ((o1, o2) -> o1.length() - o2.length());
    }

    public static void main(String[] args) {
        Map<String, Object> map = new HashMap<>();
        map.put("1",100);
        ConsumerInter.oneMapConsumer((maps)->{
            if (maps.containsKey("1")){
                maps.put("2", "成功");
                maps.remove("1");
            }
        }, map);
        Set<Map.Entry<String, Object>> entries = map.entrySet();
        for (Map.Entry<String, Object> m: entries) {
            System.out.println(m.getKey());
            System.out.println(m.getValue());
        }
        System.out.println(ConsumerInter.predicateString("阿里巴巴", (name) -> {
            switch (name) {
                case "zs":
                    System.out.println("xxxxxx1");
                    return true;
                case "阿里巴巴":
                    System.out.println("成功");
                    return true;
                default:
                    System.out.println("失败");
                    return false;
            }
        }));
        System.out.println(ConsumerInter.changeData(100, (s) -> {
            Integer res = (Integer) s + 20;
            return res;
        }));
    }

}
